﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DiplomaWeb.Models.ConsultantOfPart;

namespace DiplomaWeb.Models.OrderDiplom
{
    public class ConsultantsForOrderViewModel
    {
        public List<ConsultantOfPartViewModel> ConsultantsInOrder { get; set; }
        public IEnumerable<SelectListItem> ConsultantOfPartsList { get; set; }
        public Guid ConsultantOfPartsSelected { get; set; }

        public object OrderId { get; set; }
        public bool Edite { get; set; }

        public void ToViewModel(IEnumerable<Diploma.Models.ConsultantOfPart> allConsultants, Diploma.Models.OrderDiplom order, Guid orderId)
        {
            if (order.ConsultantOfParts != null)
            {
                ConsultantsInOrder = order.ConsultantOfParts.Select(r => new ConsultantOfPartViewModel
                {
                    Id = r.Id,
                    Text = r.Text
                }).ToList();
            }

            if (allConsultants != null)
            {
                ConsultantOfPartsList = allConsultants.Select(r => new SelectListItem
                {
                    Value = r.Id.ToString(),
                    Text = r.Text
                }).ToList();
            }

            OrderId = orderId;

            switch (order.OrderStatu.Value)
            {
                case 0:
                    Edite = true;
                    break;
                default:
                    Edite = false;
                    break;
            }
        }
    }
}